<template>
  <div class="container">
    <el-row :gutter="20" type="flex" justify="space-around">
      <el-col :span="10">
        <el-card  >
          <el-form :model="teamList" label-width="150px" label-position="left">
            <el-form-item label="报警种类：">
              <el-select
                v-model="teamList.ALARM_TYPE"
                style="width: 65%"
                disabled
              >
                <el-option
                  v-for="item in form.alermTypeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="报警阈值（分钟）：">
              <el-input
                type="number"
                v-model="teamList.ALARM_TIME"
                style="width: 65%"
              >
              </el-input>
            </el-form-item>
          </el-form>

          <el-button
            type="primary"
            @click="setWorkingHours"
            style="margin-bottom: 10px"
            >修改阈值</el-button
          >
        </el-card>
      </el-col>
      <el-col :span="10">
        <el-card class="box-card">
          <el-form :model="teamList1" label-width="150px" label-position="left">
            <el-form-item label="报警种类：">
              <el-select
                v-model="teamList1.ALARM_TYPE"
                style="width: 65%"
                disabled
              >
                <el-option
                  v-for="item in form.alermTypeList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="报警阈值（分钟）：">
              <el-input
                type="number"
                v-model="teamList1.ALARM_TIME"
                style="width: 65%"
              >
              </el-input>
            </el-form-item>
          </el-form>

          <el-button
            type="primary"
            @click="setWorkingHours1"
            style="margin-bottom: 10px"
            >修改阈值</el-button
          >
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import '@/assets/css/common.css'
import { formatDate } from '@/common/js/date.js'
import export2Excel from '@/utils/exportExcel/index.js'
export default {
  data () {
    return {
      form: {
        alermTypeList: [{ label: '滞留报警', value: '1' }, { label: '出区域报警', value: '2' }],
        alermTypeValue: '1',
        StartDate: formatDate(new Date(new Date().getTime() - 3600 * 1000 * 24), 'yyyy-MM-dd'),
        EndDate: formatDate(new Date(new Date().getTime()), 'yyyy-MM-dd hh:mm'),
      },
      teamValue: '',
      teamList: { "ALARM_TYPE": "1", "ALARM_TIME": "30" },
      teamList1: { "ALARM_TYPE": "2", "ALARM_TIME": "30" }
    }
  },
  created () {
  },
  mounted () {
    this.getRoadList()
    this.getRoadList1()
  },
  methods: {
    // 获得数据
    async getRoadList () {
      var url = "Worker/GetDisposeAlarmSetYL?ATYPE=" + this.teamList.ALARM_TYPE; // zxdata
      let { data } = await this.$Http.get(url);

      this.teamList = data[0];
    },
    // 获得数据
    async getRoadList1 () {
      var url = "Worker/GetDisposeAlarmSetYL?ATYPE=" + this.teamList1.ALARM_TYPE; // zxdata
      let { data } = await this.$Http.get(url);

      this.teamList1 = data[0];
    },
    // 下发任务
    async setWorkingHours () {
      this.$axios({
        url: 'Worker/UpdateDisposeAlarmSetYL',
        method: 'get',
        params: {
          ATYPE: this.teamList.ALARM_TYPE,
          ATIME: this.teamList.ALARM_TIME,
        },

      }).then((res) => {
        console.log(this.data)
        console.log(res)
        if (res.data.IsSucess) {
          this.$message({
            showClose: true,
            message: '修改成功',
            type: 'success'
          })
        } else {
          this.$message({
            showClose: true,
            message: '修改失败',
            type: 'error'
          })
        }
      })
    },
    // 下发任务
    async setWorkingHours1 () {
      this.$axios({
        url: 'Worker/UpdateDisposeAlarmSetYL',
        method: 'get',
        params: {
          ATYPE: this.teamList1.ALARM_TYPE,
          ATIME: this.teamList1.ALARM_TIME,
        },

      }).then((res) => {
        console.log(this.data)
        console.log(res)
        if (res.data.IsSucess) {
          this.$message({
            showClose: true,
            message: '修改成功',
            type: 'success'
          })
        } else {
          this.$message({
            showClose: true,
            message: '修改失败',
            type: 'error'
          })
        }
      })
    },
  }
}
</script>
<style>
.content {
  overflow-y: scroll;
}
.el-col-6 {
  min-width: 400px;
  min-height: 50px;
}
.el-table th {
  height: 40px;
}
</style>